from django.db import models
from django.contrib.auth import get_user_model

User = get_user_model()

# 1. 题目管理模块 - 题目模型
class ProjectTopic(models.Model):
    """毕业设计题目"""
    STATUS_CHOICES = (
        ('draft', '草稿'),
        ('pending', '待审核'),
        ('approved', '已通过'),
        ('rejected', '未通过'),
    )
    current_students = models.PositiveIntegerField(default=0, verbose_name="当前选题人数")
    title = models.CharField(max_length=200, verbose_name="题目名称")
    content = models.TextField(verbose_name="题目要求")
    max_students = models.PositiveIntegerField(default=1, verbose_name="最大选题人数")
    status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='draft', verbose_name="状态")
    created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='created_topics', verbose_name="创建教师")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        verbose_name = "毕业设计题目"
        verbose_name_plural = "题目管理"

    def __str__(self):
        return self.title